package WaiBao;

import java.util.Arrays;

public class ZhangYuan {
    public static void main(String[] args) {
        String[] name = {"陈赫(班长)", "郑凯(副班长)", "小李(学习委员)", "王传君(文艺委员)", "关谷", "神奇", "大师兄", "黑马", "李老板", "张老板", "啊嚣", "阿涨",
                "阿飞", "张小红", "李到货", "伸着", "金龙", "果子", "苹果", "橙子", "香蕉", "橘子", "小夏", "小小", "浩子", "小王", "小强", "掌嗨",
                "赵思露", "张苑(体育委员)"};//考生本人:张苑(体育委员)
        int[] age = {21, 22, 21, 18, 21, 22, 21, 21, 19, 20, 19, 18, 21, 21, 21, 19, 18, 19, 18, 20, 19, 19, 20, 20, 21, 18, 20, 20, 18, 20};//考生年龄20

        double[] zhong1 = {68, 82, 85, 60, 88, 89, 78, 59, 60, 74, 90, 87, 85, 77, 65, 68, 69, 90, 96, 88, 95, 91, 95, 85, 75, 74, 74, 81, 80, 94};
        double[] zhong2 = {81, 76, 77, 87, 65, 67, 91, 79, 85, 90, 94, 74, 86, 75, 65, 75, 86, 79, 66, 68, 82, 71, 85, 85, 75, 89, 74, 83, 87, 95};
        double[] zhong3 = {74, 89, 89, 95, 90, 79, 69, 84, 80, 60, 83, 87, 85, 85, 65, 98, 89, 79, 96, 63, 92, 81, 95, 85, 76, 88, 73, 71, 74, 95};



        double hao1;//代表每个学生的总分
        double hao2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            hao1 = zhong1[i] + zhong2[i] +zhong3[i];
//            hao2 = (hao1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" +hao1);
//            System.out.println(name[i] + "的平均分为:" +hao2);
//        }


        double pian1 = 0,pian2 = 0;
        double[] Array = new double[30];
//        for (int i = 0; i < 30; i++) {
//            pian1 = zhong1[i] + zhong2[i] + zhong3[i];
//            pian2 = (pian1 * 1.0) / 3;
//            Array[i] = pian2;
//        }
//
//        for (int i = 0; i < Array.length - 1; i++) {
//            for (int j = 0; j < Array.length - i - 1; j++) {
//                if (Array[j] < Array[j + 1]) {
//                    double temp = Array[j];
//                    Array[j] = Array[j + 1];
//                    Array[j + 1] = temp;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(Array[i]);
//        }


        double penwu1 = 0,penwu2 = 0,penwu3 = 0;//计算每门课的平均分
        double f1 = 0, f2 = 0, f3 = 0;//计算每门课标准差
        double ciwo1 = 0, ciwo2 = 0, ciwo3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < zhong1.length; i++) {
            sum2+=zhong1[i];
        }
        penwu1 = (sum2*1.0)/30;
        System.out.println("分析化学的班级平均分为:"+penwu1);
        double Sum = 0;
        for (int i = 0; i <zhong2.length; i++) {
            Sum+=zhong2[i];
        }
        penwu2 = (Sum*1.0)/30;
        System.out.println("线性代数的班级平均分为:"+penwu2);
        double sum = 0;
        for (int i = 0; i <zhong3.length; i++) {
            sum+=zhong3[i];
        }
        penwu3 = (sum*1.0)/30;
        System.out.println("有机化学的班级平均分为:"+penwu3);



        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i <zhong1.length; i++) {
            c1+= (zhong1[i] - penwu1)*(zhong1[i] - penwu1);
        }
        f1 = Math.sqrt(c1*1.0/30);
        System.out.println("分析化学的班级标准差为:"+f1);

        for (int i = 0; i < zhong2.length; i++) {
            c2+= (zhong2[i] - penwu2)*(zhong2[i] - penwu2);
        }
        f2 = Math.sqrt(c2*1.0/30);
        System.out.println("线性代数的班级标准差为:"+f2);

        for (int i = 0; i < zhong3.length; i++) {
            c3+= (zhong3[i] -penwu3)*(zhong3[i] - penwu3);
        }
        f3 = Math.sqrt(c3*1.0/30);
        System.out.println("有机化学的班级标准差为:"+f3);
//////
        Arrays.sort(zhong1);
        Arrays.sort(zhong2);
        Arrays.sort(zhong3);
        ciwo1 =( zhong1[15]+zhong1[14])*1.0/2;
        ciwo2 =( zhong2[15]+zhong2[14])*1.0/2;
        ciwo3 =( zhong3[15]+zhong3[14])*1.0/2;
        System.out.println("分析化学的中位数为:"+ciwo1);
        System.out.println("线性代数的中位数为:"+ciwo2);
        System.out.println("有机化学学的中位数为:"+ciwo3);


    }
}

